﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;

namespace Webbshop
{
    public static class Validator
    {
        /// <summary>
        /// Control if Name only contains letters
        /// </summary>
        /// <param name="name">The name of the user</param>
        /// <returns>Boolean: if the param pass the inputtest</returns>
        public static bool isLettersCorrect(String name)
        {
            return new Regex("(^[a-zA-ZåäöÅÄÖ\\s]+$)").IsMatch(name);
        }

        /// <summary>
        /// Control if input follows form, correct letters and symbols
        /// </summary>
        /// <param mail="mail">The users mail</param>
        /// <returns>Boolean: if the param pass the inputtest</returns>
        public static bool isMailCorrect(String mail)
        {
            return new Regex(@"\b([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})\b").IsMatch(mail);
        }

        /// <summary>
        /// Control if input only contains numbers
        /// </summary>
        /// <param number="number">The user Phonenumber</param>
        /// <returns>Boolean: if the param pass the inputtest</returns>
        public static bool isNumbersCorrect(String number)
        {
            return new Regex("^[0-9]+$").IsMatch(number);
        }

        public static bool isLanguageSelectCorrect(String language) {
            return new Regex("(swe)|(eng)").IsMatch(language);
        }
    }   
}